package cn.itcast.mq.springmq;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.HashMap;

@RunWith(SpringRunner.class)
@SpringBootTest
public class sendtest {
    @Resource
    RabbitTemplate rabbitTemplate;

    @Test
    public void testsend1(){
        String queueName = "simple.queue";
        String message = "hello liliang";
        rabbitTemplate.convertAndSend(queueName,message);
        System.out.println("rabbitmq信息发送成功！");
    }

    @Test
    public void testsend2(){
        String exchangeName = "itcast.fanout";
        String message = "hello liliang";
        rabbitTemplate.convertAndSend(exchangeName,"",message);
        System.out.println("rabbitmq信息发送成功！");
    }

    @Test
    public void testsend3(){
        String exchangeName = "itcast.direct";
        String message = "hello liliang";
        rabbitTemplate.convertAndSend(exchangeName,"blue",message);
        System.out.println("rabbitmq信息发送成功！");
    }
    @Test
    public void testsend4(){
        String exchangeName = "itcast.direct";
        String message = "hello liliang";
        rabbitTemplate.convertAndSend(exchangeName,"red",message);
        System.out.println("rabbitmq信息发送成功！");
    }
    @Test
    public void testsend5(){
        String exchangeName = "itcast.topic";
        String message = "hello liliang";
        rabbitTemplate.convertAndSend(exchangeName,"USA.news",message);
        System.out.println("rabbitmq信息发送成功！");
    }

    @Test
    public void testsend6(){
        String queueName = "ll.queue1";
        HashMap<String, String> map = new HashMap<>();
        map.put("name","柳岩");
        map.put("age","18");
        rabbitTemplate.convertAndSend(queueName,map);
        System.out.println("rabbitmq信息发送成功！");
    }
}
